﻿using System;
using System.Collections.Generic;
using System.Text;

namespace EmbeddedSharp.Core.Function.Expressions {
    class PrecedenceNode : FuncNode {

        public PrecedenceNode()
            : base()
        {
            base.Value = "precedence";
        }

        public override object Evaluate() {
            if (Parameters.Count < 1) {
                throw new Exception("usage: precedence(funcName)");
            }

            if (Parameters[0] is FuncNode) {
                FuncNode fn = Parameters[0] as FuncNode;
                return fn.Precedence;
            } else {
                throw new Exception(
                    "Argument is not a function node and thus does not have a precedence.");
            }
        }
    }
}
